<h1>Checkout</h1>
<? $total = 0; ?>
<? if (count($items)): ?>
<p>PayPal Processing Fee: 3% of order plus $0.30</p>
	<table class="threew25s comment">
			<tr>
				<th class="w50 left padding10">
					Item
				</th>
				<th style="width: 15%" class="left padding10">
					Quantity
				</th>
				<th style="width: 15%" class="left padding10">
					Price
				</th>
				<th style="width: 20%" class="left padding10">
					Total price
				</th>
			</tr>
		<? foreach ($items as $item): ?>
			<? if($item['discount'] != 0): ?>
			<? $discount = $item['price']; ?>
			<? if($item['id'] != 103): ?>
			<tr>
				<td class="w50 darkBlue padding10">
					<?=Html::anchor(
						Request::$controller . 'deleteItem/' . $item['section'] . '/' . $item['token'] . '/',
						'<img src="/images/icons/small/remove.png" width="12" height="12" alt="Remove form cart"/>'
					)?>
					<?=Html::chars($item['name'])?>
				</td>
				<td style="width: 15%" class="padding10">
					<?=$item['quantity']?>
				</td>
				<td style="width: 15%" class="padding10">
					<?=$item['price']?>%
				</td>
				<td style="width: 20%" class="padding10">
					<?=$item['price']?>%
				</td>
			</tr>
			<? endif; ?>
			<? else: ?>
			<? $total += (round(((float)$item['price'] * (int)$item['quantity']) * 100) / 100); ?>
			<tr>
				<td class="w50 darkBlue padding10">
					<?=Html::anchor(
						Request::$controller . 'deleteItem/' . $item['section'] . '/' . $item['token'] . '/',
						'<img src="/images/icons/small/remove.png" width="12" height="12" alt="Remove form cart"/>'
					)?>
				  <? if($item['price'] == 0): ?>
					Discount for: <?=Html::chars($item['name'])?>
				  <? else: ?>
					<?=Html::chars($item['name'])?>
				  <? endif; ?>
				</td>
				<td style="width: 15%" class="padding10">
				  <? if($item['price'] == 0): ?>
					&nbsp;
				  <? else: ?>
					<?=$item['quantity']?>
				  <? endif; ?>
				</td>
				<td style="width: 15%" class="padding10">
				    <? if($item['price'] == 0): ?>
				    &nbsp;
				    <? else: ?>
				    $<?=$item['price']?>
				    <? endif; ?>
				</td>
				<td style="width: 20%" class="padding10">
				    <? if(round(((float)$item['price'] * (int)$item['quantity']) * 100) / 100 == 0): ?>
				    50%
				    <? else: ?>
				    $<?=(round(((float)$item['price'] * (int)$item['quantity']) * 100) / 100)?>
				    <? endif; ?>
				</td>
			</tr>
			<? endif; ?>
		<? endforeach ?>
		<? if (isset($delivery)): ?>
			<tr>
				<td class="padding10 right" colspan="3">
				<script type="text/javascript">
					function calculateDelivery(el)
					{
						var total = document.getElementById('totalAmount');
						var delivery = document.getElementById('customer-delivery'); if (el.checked) {delivery.value = 1; total.innerHTML = '$<?=$total + $delivery?>';} else {delivery.value = 0; total.innerHTML = '$<?=$total?>';}
					}
				</script>
					Overnight delivery: <input type="checkbox" onclick="calculateDelivery(this)" />
				</td>
				<td style="width: 20%" class="padding10">
					 $<?=$delivery?>
				</td>
			</tr>
		<? endif ?>
		<tr>
			<td class="padding10 bold right" colspan="3">
				Total:
			</td>
			<td style="width: 20%" class="padding10 bold">
			<?php
				$cent = $total * 3 / 100;
				$total = $total + $cent;
			?>
				<? if(isset($discount)): ?>
			    <span id="totalAmount">$<?=round($total * $discount / 100, 2); ?></span>
				<? else: ?>
			    <span id="totalAmount">$<?=round($total, 2); ?></span>
				<? endif; ?>
			</td>
		</tr>
	</table>
<? endif ?>
<p>
	<a href="/membership/" class="large darkBlue">&larr; Go Back</a>
</p>
<!--<p class="large">Fill up this fields to proceed to the PayPal secure checkout</p>-->
<? if (isset($form)): ?>
	<?=$form?>
<? endif?>
<p>
To avoid processing fees please mail a print out of your application and check payable to West Town Chamber of Commerce to 1819 W. Chicago Ave., Chicago, IL 60622
</p>